using System;
using CommunityToolkit.Mvvm.ComponentModel;

namespace mas.Models;

// 日志级别枚举
public enum LogLevel
{
    Info,
    Warning,
    Error
}

// 日志消息模型
public partial class LogMessage : ObservableObject
{
    public DateTime Timestamp { get; }
    public LogLevel Level { get; }
    public string Message { get; }

    // 根据日志级别返回对应的显示颜色
    public string LevelColor => Level switch
    {
        LogLevel.Info => "#000000",    // 黑色
        LogLevel.Warning => "#FFA500", // 橙色
        LogLevel.Error => "#FF0000",   // 红色
        _ => "#000000"
    };

    public LogMessage(LogLevel level, string message)
    {
        Timestamp = DateTime.Now;
        Level = level;
        Message = message;
    }

    // 格式化显示文本
    public override string ToString()
    {
        return $"[{Timestamp:HH:mm:ss}] [{Level}] {Message}";
    }
}